package com.tju.shortlink.project.controller;

import com.tju.shortlink.project.common.convention.result.Result;
import com.tju.shortlink.project.common.convention.result.Results;
import com.tju.shortlink.project.service.IUrlTitleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * URL标题控制层
 */
@RestController
@RequestMapping("/api/short-link/v1")
@RequiredArgsConstructor
public class UrlTitleController {

    private final IUrlTitleService titleService;

    @GetMapping("title")
    public Result<String> getTitleByUrl(@RequestParam("url") String url){
        String title = titleService.getTitleByUrl(url);
        return Results.success(title);
    }



}
